<?php
require("../../DBops.php");
session_start();

$havedonevalue = $_POST['havedonevalue'];
$notyetvalue = $_POST['notyetvalue'];
$plan = $_POST['plan'];

$con = connect("localhost", "root", "", "lab");
//echo $_SESSION['user'];
if(isset($_SESSION['user']))
{
	
	$result = query($con, "*", "personalinfo", "ID", $_SESSION['user']);
			$row = mysql_fetch_array($result);
			$teamid=$row['projecteamID'];
	

	$result = query($con, "name", "projecteam", "ID", $teamid);
	$row = mysql_fetch_array($result);
	$teamname=$row['name'];
	
	date_default_timezone_set ('PRC');
	$data = array($teamid, $teamname, $havedonevalue, $notyetvalue, $plan, date('Y-m-d H:i:s',time()),$teamid);
	//$sql = "delete from weeklyreport where datetime = (select datetime from (select * from weeklyreport where ID = '$teamid') a  order by datetime desc limit 1)";
	//mysql_query($sql, $con);
	if($_GET['type'] == 'edit')
	{
		$sql = "delete from weeklyreport where datetime = (select datetime from (select * from weeklyreport where ID = '".$teamid."') a order by datetime desc limit 1)";
		mysql_query($sql, $con);
	}
		insertIntoDB($con, "weeklyreport", $data);
		echo "<script>location.href='Conference_report.php?id=$teamid';</script>"; 
}

